package com.cx.util;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author onoo
 * @create 2021-08-15
 **/
public class OssUtil {

    public static void main(String[] args) {
        String accessKey = "GmryKxFYNJ2SqV6cODJ8";
        String secretKey = "UVub7QdsWpMIVl9n4H1wVQQILFyzdiR7dqNZmjRe";
        String endPoint = "cqoss.xstore.ctyun.cn";
        BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration (endPoint, Regions.DEFAULT_REGION.getName());
        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
                //客户端设置
                .withClientConfiguration(clientConfiguration)
                //凭证设置
                .withCredentials(new AWSStaticCredentialsProvider (credentials))
                //endpoint设置
                .withEndpointConfiguration(endpointConfiguration)
                .build();

    }

}
